// 使用接口来固定数组中索引和值的类型

// 索引：要求是数值类型
// 值：要求是字符串类型
interface namelist {
    [index:number]:string
}

// 对象要求，key必须是数值，value是字符串即可
let nl1:namelist = ["Hydra","Haozhe","Yuxin"];
let nl2:namelist = {1:"奉先",2:"罗佰君",3:"刘煜鑫"};

console.log(nl1[0]);
console.log(nl2[1]);

// 思考？如果要求索引时字符串，值是数值如何定义？
interface agelist {
    [index:string]:number
}

let al1:agelist = {
    "奉先": 35,
    "刘煜鑫": 26,
    "罗佰君": 24,
}

console.log(al1["奉先"]);


interface mylist {
    [index:string]:namelist
}

let t1:mylist = {
    "1组": ["罗佰君","唐晨","李杰"],
    "2组": ["刘煜鑫","伍雨薇","李红梅"],
    "3组": ["王彦琪","郑涛","黄俊翔"],
}